NBA

Matthew Tung

8/3/2021

Introduction

As NBA progresses, so does the game. The game has become more reliant on 3 pointers. Thus, I have created a simple linear regression model that models 3 point percentage against plus and minus.

Users can input their favorite players’ 3 point percentage and see how much influence they can have on today’s game.

Data Source

Data source is from nbastatr: https://www.rdocumentation.org/packages/nbastatR/versions/0.1.10131 In this dataset, I used 2020’s NBA season. I used a simple linear regression model to estimate Ratio BPM from players’ 3 PT Percentage.

Plus minus Indications (From Basketball-Reference.com)

Backend

library(nbastatR)
library(plotly)
season2020 <- bref_players_stats(season = 2020)
FALSE parsed http://www.basketball-reference.com/leagues/NBA_2020_advanced.html
FALSE parsed http://www.basketball-reference.com/leagues/NBA_2020_totals.html
FALSE Advanced
FALSE Totals
season2020 <- season2020[season2020[, 'fg3aTotals'] >= 150,]
fit1 <- lm(formula = ratioBPM~pctFG3, data=season2020)
summary(fit1)
FALSE 
FALSE Call:
FALSE lm(formula = ratioBPM ~ pctFG3, data = season2020)
FALSE 
FALSE Residuals:
FALSE     Min      1Q  Median      3Q     Max 
FALSE -5.6763 -1.8823 -0.3944  1.1585 12.1176 
FALSE 
FALSE Coefficients:
FALSE             Estimate Std. Error t value Pr(>|t|)  
FALSE (Intercept)   -4.340      2.122  -2.045   0.0422 *
FALSE pctFG3        12.243      5.796   2.112   0.0360 *
FALSE ---
FALSE Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
FALSE 
FALSE Residual standard error: 2.824 on 187 degrees of freedom
FALSE Multiple R-squared:  0.0233,  Adjusted R-squared:  0.01808 
FALSE F-statistic: 4.462 on 1 and 187 DF,  p-value: 0.03599
fig<- plot_ly(x = season2020$pctFG3, y = season2020$ratioBPM, xlab = "3Pt Percentage", 
              ylab = "Ratio BPM", color = season2020$groupPosition, 
              size = season2020$fg3aTotals)%>%
            add_markers(y=season2020$rationBPM) %>%
            add_lines(x = season2020$pctFG3, y = fitted(fit1))%>%
            add_trace(text = season2020$namePlayer, hovertemplate=paste('Player: %{text}', 
                                                  '<br>3PT Pct: %{x}<br>', 
                                                  'RatioBPM Pct: %{y}'))
fig